package vn.sunnet.backviet01.game.coloa.human.enemy;

import org.anddev.andengine.entity.sprite.Sprite;
import org.anddev.andengine.opengl.texture.region.TextureRegion;

public class SoundCircle extends Sprite{
	private long begin;
	private float xCenter;
	private float yCenter;
	
	public SoundCircle(float pX, float pY,
			TextureRegion pTextureRegion) {
		super(pX, pY, pTextureRegion);
	}

	public void setBegin() {
		this.begin = System.currentTimeMillis();
	}
	
	public long begin() {
		return this.begin;
	}
	
	public long timeLife() {
		return System.currentTimeMillis() - begin;
	}
	
	public void onManagedUpdate(float pSecondsElapsed) {
		super.onManagedUpdate(pSecondsElapsed);
		xCenter = this.getX() + this.getWidth();
		yCenter = this.getY() + this.getHeight();
	}
	
	public boolean isInfluence(float xPos, float yPos) {
		float xOffset = this.xCenter - xPos;
		float yOffset = this.yCenter - yPos;
		
		float offset = (float)(Math.sqrt(xOffset * xOffset + yOffset * yOffset));
		
		if (offset < 100)
			return true;
		return false;
	}
}
